package com.eight.uploud.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.eight.common.pojo.EduCourse;
import com.eight.common.pojo.TbMember;
import com.eight.uploud.mapper.EduCourseMapper;
import com.eight.uploud.mapper.TbMemBerMapper;
import com.eight.uploud.mapper.TbShoucangCourseMapper;
import com.eight.uploud.service.TbMemBerService;
import com.eight.uploud.vo.ShouCangVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @program: qy8-education
 * @description:
 * @author: 平家祥
 * @create: 2023-06-05 10:06
 **/
@Service
public class TbMemBerServiceImpl implements TbMemBerService {
    @Autowired
    TbMemBerMapper mapper;
    @Override
    public TbMember selectOneByMobile(String mobile) {
        QueryWrapper<TbMember> tbMemberQueryWrapper = new QueryWrapper<>();
        tbMemberQueryWrapper.eq("mobile",mobile);
        return mapper.selectOne(tbMemberQueryWrapper);
    }

    @Override
    public Integer updateByMobile(TbMember tbMember) {
        tbMember.setGmtModified(LocalDateTime.now());
        return mapper.updateById(tbMember);
    }

    /**
     * 个人收藏
     */
    @Autowired
    EduCourseMapper eduCourseMapper;
    @Override
    public List<EduCourse> findByHuiYuanId(String huiYuanId) {
        return eduCourseMapper.findByHuiYuanId(huiYuanId);
    }

    @Autowired
    TbShoucangCourseMapper tbShoucangCourseMapper;
    @Override
    public Integer deleteFavoriteCourse(ShouCangVo shouCangVo) {
        String memberid = shouCangVo.getMemberid();
        String courseid = shouCangVo.getCourseid();
        Integer integer = tbShoucangCourseMapper.deleteFavoriteCourse(memberid, courseid);
        return integer;
    }
}
